package org.sy.lab.Java7并发编程实战.三线程同步辅助类.六并发阶段任务中的阶段切换;

public class Main {
	public static void main(String args[]) {
		MyPhaser phaser = new MyPhaser();
		Student student[] = new Student[5];
		for(int i=0; i<student.length; i++) {
			student[i] = new Student(phaser);
			phaser.register();
		}
		Thread threads[] = new Thread[student.length];
		for(int i=0; i<student.length; i++) {
			threads[i] = new Thread(student[i], "Student" + i);
			threads[i].start();
		}
		for(int i=0; i<student.length; i++) {
			try {
				threads[i].join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		System.out.printf("Main: The phaser has finished: %s.\n", phaser.isTerminated());
	}
}
